package com.example.bootweb.service;

import com.example.bootweb.entity.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserService implements UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        //检查是不是登录
        if (username.equals("admin")){
            return new User().setUsername("admin").setPassword("123456");
        }
         throw new UsernameNotFoundException("用户不存在");

    }
}
